package wineshop.service.Impl;

import java.util.List;

import wineshop.dao.DaoFactory;
import wineshop.dao.RoomDao;
import wineshop.domain.Room;
import wineshop.service.RoomQueryHelper;
import wineshop.service.RoomService;
import wineshop.utils.Page;

public class RoomServiceImpl implements RoomService {

	public void CreateRoom(Room room) {
		RoomDao roomDao = (RoomDao) DaoFactory.GetDao("roomDao");
		roomDao.AddRoom(room);

	}

	public List<Room> GetAllRoom() {
		RoomDao roomDao = (RoomDao) DaoFactory.GetDao("roomDao");
		return roomDao.GetAllRoom();

	}

	public Room GetRoomById(int roomId) {
		RoomDao roomDao = (RoomDao) DaoFactory.GetDao("roomDao");
		return roomDao.GetRoomById(roomId);

	}

	public void removeRoom(int roomId) {
		RoomDao roomDao = (RoomDao) DaoFactory.GetDao("roomDao");
		roomDao.delRoom(roomId);

	}

	public void UpdateRoom(Room room) {
		RoomDao roomDao = (RoomDao) DaoFactory.GetDao("roomDao");
		roomDao.UpdateRoom(room);

	}

	public Page loadRoomsByCondition(RoomQueryHelper helper, Page page) {

		RoomDao roomDao = (RoomDao) DaoFactory.GetDao("roomDao");
		page.setTotalRecNum(roomDao.countRoomsByCondition(helper));
		page.setPageContent(roomDao.getScopedRooms(helper,
				page.getStartIndex(), page.getPageSize()));

		return page;
	}
}
